<template>
	<view class="collection" v-if="ColleList.length >= 1">
		<view class="item common" v-for="(item,i) in ColleList" :key="i" @click="ToCleaner(item.id)">
			<image class="img" :src="item.image" mode="aspectFill" />
			<view class="right">
				<view class="line1">
					<view class="left">
						<text class="name">{{item.name}}</text>
						<text class="city">{{item.home_city}}</text>
					</view>
					<view class="right1">
						<view class="can">{{item.day}}可约</view>
						<view class="time">{{item.works_times}}</view>
					</view>
				</view>
				<view class="line2">
					<text class="text">{{item.age}}岁</text>
					<text class="text">{{item.type}}</text>
				</view>
				<view class="line3" v-if="item.tags[0]">
					<block v-for="(items,index) in item.tags" :key="index">
						<view class="tag">{{items}}</view>
					</block>
				</view>
				<view class="fixed">
					<u-icon name="map" size="22rpx" color="#8C8C8C" />
					<text>{{(item.distance / 1000).toFixed(1)}}km</text>
				</view>
			</view>
		</view>
	</view>
	<!-- 空白页组件 -->
	<Blankpage v-else></Blankpage>
</template>

<script>
	import { ResColleList } from '@/untils/api.js'
	import { Blankpage } from '@/components/Blankpage/Blankpage.vue'
	export default {
		components: {
			Blankpage
		},
		data() {
			return {
				ColleList: []
			}
		},
		onLoad() {
			this.getColleList()
		},

		methods: {
			ToCleaner(id) {
				uni.navigateTo({
					url: `/pages/Home/Cleaner?id=${id}`
				})
			},
			async getColleList() {
				const { data: res } = await ResColleList()
				this.ColleList = res.data.data
				console.log(res, '收藏列表');
			}
		}
	}
</script>

<style lang="scss" scoped>
	.common {
		padding: 0 20rpx 0 32rpx;
		box-sizing: border-box;
	}

	.collection {
		font-family: PingFangSC-Regular, PingFang SC;
	}



	.item {
		display: flex;
		align-items: flex-start;
		margin-top: 34rpx;
	}

	.item .img {
		width: 180rpx;
		height: 200rpx;
		border-radius: 8rpx;
		margin-right: 18rpx;
	}

	.right {
		height: 200rpx;
		position: relative;
		flex: 1;
		padding-bottom: 40rpx;
		border-bottom: 1rpx solid #EFEFEF;
	}

	.item .line1 {
		display: flex;
		justify-content: space-between;
		align-items: flex-end;
	}

	.item .line1 .left .name,
	.city {
		margin-right: 13rpx;
		height: 37rpx;
		font-size: 26rpx;
		font-weight: 400;
		color: #070A16;
		line-height: 37rpx;
	}

	.item .line1 .right1 {
		display: flex;
		align-items: center;
		border-radius: 4rpx;
		border: 1rpx solid #EE4040;
		font-size: 18rpx;
	}

	.item .line1 .right1 .can {
		padding: 6rpx;
		text-align: center;
		background: #EE4040;
		border-radius: 4rpx 0rpx 0rpx 4rpx;
		color: #FFF6F6;
	}

	.item .line1 .right1 .time {
		padding: 4rpx;
		color: #DF4B38;
	}

	.line2 {
		margin: 10rpx 0;
	}

	.line2 .text {
		font-size: 24rpx;
		font-weight: 400;
		color: #212121;
		padding: 0 10rpx;
		border-right: 1rpx solid #D4D4D4;
	}

	.line2 .text:first-child {
		padding-left: 0;
	}

	.line2 .text:last-child {
		border-right: 0;
	}

	.line3 {
		width: 420rpx;
		display: flex;
		flex-wrap: wrap;
	}

	.line3 .tag {
		font-size: 20rpx;
		font-weight: 400;
		color: #686B72;
		padding: 4rpx 8rpx;
		border-radius: 4rpx;
		border: 1rpx solid #979797;
		margin-right: 10rpx;
		margin-bottom: 10rpx;
	}

	.right .fixed {
		position: absolute;
		right: 0;
		top: 53rpx;
		font-size: 22rpx;
		font-weight: 400;
		color: #8C8C8C;
	}
</style>
